import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

// TODO: 扩展权限
@Schema({ timestamps: { createdAt: 'createTime', updatedAt: 'updateTime' } })
export class Auth {
  @Prop({ unique: true, type: String })
  userId: string;

  @Prop({ default: [], type: [String] })
  systemUser: string[];

  @Prop({ default: [], type: [String] })
  systemLog: string[];

  @Prop({ default: [], type: [String] })
  model: string[];

  @Prop({ default: [], type: [String] })
  shader: string[];

  @Prop({ default: [], type: [String] })
  effects: string[];

  @Prop({ default: [], type: [String] })
  game: string[];

  @Prop({ default: [], type: [String] })
  tool: string[];

  @Prop({ type: Date })
  createTime: Date;

  @Prop({ type: Date })
  updateTime: Date;
}

export type AuthDocument = Auth & Document;
export const AuthSchema = SchemaFactory.createForClass(Auth);
AuthSchema.index({ createTime: -1 });
AuthSchema.index({ updateTime: -1 });
